package com.ruoyi.bigScreen.controller;

import com.ruoyi.bigScreen.domain.vo.BigScreenDataQualityVO;
import com.ruoyi.bigScreen.service.IBigScreenDataQualityService;
import com.ruoyi.common.core.constant.HttpStatus;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 完整率
 *
 * @author hwd
 * @date 2023-02-16
 */
@RestController
@RequestMapping("/BigScreenDataQuality")
public class BigScreenDataQualityController extends BaseController
{

    @Autowired
    private IBigScreenDataQualityService bigScreenDataQualityService;


    /**
     * 显示各机管机构的数据完整率及逐级汇总数据
     * 数据权限过滤
     */
    @GetMapping("/listBigScreenStationDataWzl")
    public AjaxResult listBigScreenStationDataWzl(BigScreenDataQualityVO dataQualityVO) throws ParseException {
        dataQualityVO.setStatType(2);
        List<BigScreenDataQualityVO> voList=bigScreenDataQualityService.listStationDataWzl(dataQualityVO);
        if (voList.size()>0){// 返回 对象集合以类属性一降序 属性二降序 注意两种写法
            voList=voList.stream().sorted(Comparator.comparing(BigScreenDataQualityVO::getYbCount).reversed().thenComparing(BigScreenDataQualityVO::getSbCount,Comparator.reverseOrder())
        )
                .collect(Collectors.toList());
        }
        return AjaxResult.success(voList);
    }


}
